using System;
using System.Collections.ObjectModel;
using System.Windows;
namespace MicroMsg.UI.UserContrl
{
	public class MMObservableCollection<DataType, CtrlType> : ObservableCollection<DataType> where DataType : IListDataItem where CtrlType : DependencyObject
	{
		private MMListBox mMMListBox;
		public DataType this[int index]
		{
			get
			{
				return base.get_Item(index);
			}
			set
			{
				IListDataItem listDataItem = value;
				listDataItem.FillData(base.get_Item(index));
				if (this.mMMListBox != null)
				{
					this.mMMListBox.Refresh<CtrlType>(index);
				}
			}
		}
		public void Bind(MMListBox _MMListBox)
		{
			this.mMMListBox = _MMListBox;
			this.mMMListBox.set_ItemsSource(this);
		}
		public void UnBind()
		{
			if (this.mMMListBox != null)
			{
				this.mMMListBox.set_ItemsSource(null);
				this.mMMListBox = null;
			}
		}
	}
}
